import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
ss = Service('chromedriver.exe')
driver = webdriver.Chrome(service=ss)
driver.implicitly_wait(15)
driver.get("https://www.126.com/")
driver.maximize_window()
#定位到iframe框架
# iframe = driver.find_elements(By.TAG_NAME,"iframe")[0]
# iframe = driver.find_element(By.XPATH,"//*[@scrolling='no']")
iframes = driver.find_elements(By.TAG_NAME,"iframe")
for iframe in iframes:
    if iframe.get_attribute("frameborder") == "0":
            # 跳进iframe
        driver.switch_to.frame(iframe)
        break
# 输入账号
driver.find_element(By.NAME,"email").send_keys("baijiacheng_123")
# 输入密码
driver.find_element(By.NAME,"password").send_keys("qwe123..")
# 点击登录
driver.find_element(By.ID,"dologin").click()

# 跳出iframe，做后续操作
# 回到默认的上下文
# driver.switch_to.default_content()

# 点击未读邮件
driver.find_elements(By.CLASS_NAME,"gWel-mailInfo-txt")[0].click()
time.sleep(100)


